<template>
	<view class="content">
		<!-- 头部： -->
		<view class="header">
			<view class="img" style="background-image: url('/static/image/mine/bg.png');">
				<!-- 未登录： -->
				<view class="flexleft header_left" v-if="!is_login" @click="login">
					<view class="img_a">
						<image src="/static/bag.png" mode="widthFix"></image>
					</view>
					<view class="header_wenzi flexbetween">
						<view class="name">去登录</view>
						<u-icon name="arrow-right" color="rgba(255, 255, 255, 1)" size="16"></u-icon>
					</view>
				</view>
				<!-- 已登录： -->
				<view class="flexleft header_left" v-if="is_login" @click="gogerenxx">
					<view class="img_a">
						<image :src="userinfo.avatar" mode="widthFix"></image>
					</view>
					<view class="header_wenzi">
						<view class="flexbetween">
							<view class="name">{{userinfo.nickname}}</view>
							<u-icon name="arrow-right" color="rgba(255, 255, 255, 1)" size="16"></u-icon>
						</view>
						<view class="flexleft">
							<view class="header_shenfen margin_right1 flexleft">
								<view class="shenfen">{{userinfo.group_id_text}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 我的订单： -->
			<view class="nav order">
				<!-- 顶部标题： -->
				<view class="nav_a flexbetween">
					<view class="nav_my" style="font-size: 32rpx;">天商订单</view>
					<view class="flexleft" @click="businessOrder(0)">
						<view class="look">查看全部订单</view>
						<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
					</view>
				</view>
				<!--  -->
				<view class="nav_a flexbetween">
					<view class="fukuan_a" @click="businessOrder(1)">
						<image src="/static/image/mine/fu.png" mode="" class="me_dingdan"></image>
						<view class="nav_text">待付款</view>
					</view>
					<view class="fukuan_a" @click="businessOrder(2)">
						<image src="/static/image/mine/fen.png" mode="" class="me_dingdan"></image>
						<view class="nav_text">待分享</view>
					</view>
					<view class="fukuan_a" @click="businessOrder(3)">
						<image src="/static/image/mine/fa.png" mode="" class="me_dingdan"></image>
						<view class="nav_text">待发货</view>
					</view>
					<view class="fukuan_a" @click="businessOrder(4)">
						<image src="/static/image/mine/shou.png" mode="" class="me_dingdan"></image>
						<view class="nav_text">待收货</view>
					</view>
					<view class="fukuan_a" @click="refund">
						<image src="/static/image/mine/tui.png" mode="" class="me_dingdan"></image>
						<view class="nav_text">退款</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 下方列表： -->
		<view class="center" style="margin-top: 220rpx;">
			<view class="center_a flexbetween" @click="goServiceOrder">
				<view class="flexleft">
					<view class="lijuan"></view>
					<view class="title">服务订单</view>
				</view>
				<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
			</view>
			<view class="center_a flexbetween" @click="goBusinessSettled">
				<view class="flexleft">
					<view class="shangcheng"></view>
					<view class="title">商家入驻</view>
				</view>
				<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
			</view>
			<view class="center_a flexbetween" @click="goMineRelease">
				<view class="flexleft">
					<view class="yaoqing"></view>
					<view class="title">我的发布</view>
				</view>
				<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
			</view>
			<view class="center_a flexbetween" @click="goMineCollect" v-if="userinfo.user_level_id!=1">
				<view class="flexleft">
					<view class="yaoqing1"></view>
					<view class="title">我的收藏</view>
				</view>
				<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
			</view>
			<view class="center_a flexbetween" @click="phone">
				<view class="flexleft">
					<view class="kefu"></view>
					<view class="title">联系客服</view>
				</view>
				<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
			</view>
			<view class="center_a flexbetween" @click="set">
				<view class="flexleft">
					<view class="shezhi"></view>
					<view class="title">设置</view>
				</view>
				<u-icon name="arrow-right" color="rgba(175, 175, 175, 1)" size="12"></u-icon>
			</view>
		</view>
		<u-modal :show="loshow" :title="lotitle" :showCancelButton="true" confirmColor="#ff740e" @cancel="locancel"
			@confirm="loconfirm" confirmText="去登录"></u-modal>
		<tabbardi :current="4"></tabbardi>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				loshow: false, //登录弹窗
				lotitle: '请登录后再查看!',
				is_login: true,
				userinfo: {},
				stateShenHe: 0, //审核状态:1=审核中,2=审核通过,3=审核未通过
				tel:"",//客服电话
			};
		},
		onLoad() {
			uni.hideTabBar()
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.getinfo()
				this.getRuzhuinfo()
				this.getHomeInit()
			} else { //退出清空数据
				this.userinfo = {}
			}
		},
		methods: {
			getRuzhuinfo() {
				httpRequest.request('/api/shop/apply_pre', 'GET', {}).then(res => {
					if (res.data.info) {
						this.stateShenHe = res.data.info.state
					}
				})
			},
			locancel() {
				this.loshow = false;
			},
			loconfirm() {
				this.loshow = false;
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			getinfo() {
				let _this = this
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userinfo = res.data
				})
			},
			businessOrder(value) { //我的订单 //0全部，1待付款，2待分享， 3待发货，4待收货，5已完成
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_mine/businessOrder?value=" + value
				})
			},
			goServiceOrder() { //服务订单
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_mine/serviceOrder"
				})
			},
			goBusinessSettled() { //商家入驻、商家入口
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				if (this.stateShenHe == 0) {
					uni.navigateTo({
						url: "/pages_mine/businessSettled"
					})
				} else {
					uni.navigateTo({
						url: "/pages_mine/examine"
					})
				}
			},
			goMineRelease() { //我的发布
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_mine/mineRelease"
				})
			},
			goMineCollect() { //我的收藏
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_mine/mineCollect"
				})
			},
			// 获取客服电话
			getHomeInit() {
				httpRequest.request("/api/index/index", "GET", {}).then(res => {
					this.tel=res.data.client_tel
					// this.$store.commit("setClient_tel", res.data.client_tel)
				})
			},
			phone() { //联系客服
				uni.makePhoneCall({
					phoneNumber: this.tel.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			},
			// 跳转 我的兑换券
			gowddhj() {
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_my/wodedhj"
				})
			},
			// 跳转 我的礼券
			gowdlj() {
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_my/wodelj"
				})
			},
			// 跳转 礼券商城
			goljsc() {
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_my/lijuansc"
				})
			},
			// 跳转 邀请中心
			goyqzx() {
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_my/yaoqingzx"
				})
			},
			// 跳转 经销商
			gojxs() {
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_my/jingxiaos"
				})
			},
			set() {
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_mine/setUp"
				})
			},
			refund() { //退款
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: "/pages_mine/refundOrder"
				})
			},
			gouwujin() { //跳转到我的购物金
				let _this = this
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: '/pages_my/wodegwj'
				})
			},
			tzyue() { //跳转余额
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: '/pages_my/wodeye'
				})
			},
			// 跳转 个人信息
			gogerenxx() {
				uni.navigateTo({
					url: '/pages_mine/personInformation'
				})
				return
				if (!uni.getStorageSync('token')) {
					this.loshow = true;
					return
				}
				uni.navigateTo({
					url: '/pages_mine/personInformation'
				})
			},
			login() { //去登陆
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.right_icon1 {
		width: 20.35rpx;
		height: 25.35rpx;
		background-image: url('/static/image/mine/right_icon.png');
		background-size: 100% 100%;
	}

	.order {
		position: absolute;
		top: 300rpx;
		left: 30rpx;
		right: 30rpx;
		z-index: 99;
	}

	.text {
		// padding:0 20rpx;
		position: absolute;
		top: 300rpx;
		left: 50rpx;
		right: 50rpx;
		z-index: 90;

		.textnav {
			margin: 0 auto;
			padding: 30rpx 20rpx;
			background: rgba(255, 255, 255, 0.2);
			border: 1rpx solid #FFFFFF;
			border-radius: 14rpx 14rpx 14rpx 14rpx;
			display: flex;
			align-items: center;
		}

		.imgBox {
			width: 54rpx;
			height: 44rpx;
			margin-right: 10rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.price {
			font-size: 28rpx;
			font-family: PingFang SC-Heavy, PingFang SC;
			font-weight: 800;
			color: #F3271C;
		}

		.line {
			width: 0;
			height: 17rpx;
			opacity: 0.3;
			border-right: 2rpx solid #4E2809;
			margin-right: 20rpx;
		}

		.button {
			width: 124rpx;
			height: 45rpx;
			background: #F3271C;
			border-radius: 23rpx 23rpx 23rpx 23rpx;
			text-align: center;
			line-height: 45rpx;
			font-size: 20rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}

		.nav_a {
			text-align: center;
			padding: 0;
		}

		.text_2 {
			font-size: 26rpx;
			color: #666;
		}
	}

	.content {
		background-color: #fafafa;
		min-height: 100vh;
		padding-bottom: 100rpx;
	}

	// 头部：
	.img {
		width: 750rpx;
		height: 400rpx;
		background-size: 100% 100%;
		padding-top: 150rpx;
		margin-bottom: 60rpx;
		// background-image: url('/static/image/mine/bg.png');
	}

	.flexleft {
		display: flex;
		align-items: center;
	}

	.header {
		position: relative;
	}

	.header_left {
		width: 100%;
		padding: 0 40rpx;
		box-sizing: border-box;
	}

	.img_a {
		border-radius: 50%;
		width: 110rpx;
		height: 110rpx;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.header_wenzi {
		// flex-grow: 1;
		flex: 1;
		margin-left: 30rpx;
		// padding-right: 60rpx;
		color: #fff;
	}

	.name {
		font-size: 36rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		font-weight: 800;
		color: #FFF;
	}

	.header_shenfen {
		margin-top: 20rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Heavy, PingFang SC;
		color: #FF7510;

		.shenfen {
			padding: 6rpx 20rpx;
			border-radius: 6rpx;
			margin-right: 20rpx;
			background: rgba(255, 255, 255, 0.1);
			border: 1rpx solid #FFFFFF;
			font-size: 20rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	// 商城订单：
	.nav {
		// position: absolute;
		// top: 290rpx;
		// width: 92%;
		box-sizing: border-box;
		// margin: 0rpx 30rpx 30rpx;
		padding: 22rpx 35rpx;
		background-color: #fff;
		border-radius: 14rpx;
	}

	.nav_a {
		padding: 22rpx 0rpx 22rpx 0rpx;
	}

	.nav_my {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
	}

	.look {
		margin-right: 7rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}

	.fukuan_a {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
	}

	.me_dingdan {
		width: 70rpx;
		height: 60rpx;
		background-size: 100% 100%;
	}

	.nav_text {
		margin-top: 21rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #000000;
	}

	// 下方列表：
	.center {
		margin: 30rpx;
		padding: 0 35rpx;
		background-color: #fff;
		border-radius: 14rpx 14rpx 14rpx 14rpx;
	}

	.center_a {
		border-bottom: 1rpx solid #fcfcfc;
		border-top: 1rpx solid #fcfcfc;
	}

	.contactbtn {
		background-color: #fff;
		border: none;
		font-size: 32rpx;
		line-height: 24rpx;
		color: #333;
		height: 78rpx;
		line-height: 78rpx;
		padding: 0 400rpx 0 0;
	}

	.contactbtn::after {
		border: 0;
	}

	.title {
		margin: 40rpx 20rpx;
		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.lijuan {
		width: 38rpx;
		height: 38rpx;
		background-size: 100% 100%;
		background-image: url('/static/image/mine/fuwu.png');
	}

	.shangcheng {
		width: 38rpx;
		height: 38rpx;
		background-size: 100% 100%;
		background-image: url('/static/image/mine/shangjia.png');
	}

	.yaoqing {
		width: 38rpx;
		height: 38rpx;
		background-size: 100% 100%;
		background-image: url('/static/image/mine/fabu.png');
	}

	.yaoqing1 {
		width: 38rpx;
		height: 38rpx;
		background-size: 100% 100%;
		background-image: url('/static/image/mine/shoucang.png');
	}

	.kefu {
		width: 38rpx;
		height: 38rpx;
		background-size: 100% 100%;
		background-image: url('/static/image/mine/mineKefu.png');
	}

	.shezhi {
		width: 38rpx;
		height: 38rpx;
		background-size: 100% 100%;
		background-image: url('/static/image/mine/shezhi.png');
	}
</style>